package com.example.materialtest

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_tool_bar.*

class ToolBarActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_tool_bar)
        setSupportActionBar(toolBar)

    }
    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.toolbar,menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when(item.itemId){
            R.id.close -> Toast.makeText(this, "点击第一个关闭", Toast.LENGTH_SHORT).show()
            R.id.close2 -> Toast.makeText(this, "点击第二个关闭", Toast.LENGTH_SHORT).show()
            R.id.ipt -> Toast.makeText(this, "点击导入", Toast.LENGTH_SHORT).show()
        }
        return true
    }
}